import { AxiosPromise } from "axios";
import request from "@/utils/request.ts";

// 第二种：Axios请求MockJS数据（二次封装）Api优化版
export const userLoginApi = (data: any, headers?: any) => {
  return request.post<any, any>("/user/login", data, { headers });
};
// 第二种：Axios请求MockJS数据（二次封装）Api优化版
export const userInfoApi = (params?: any, headers?: any) => {
  return request.get<any, any>("/user/info", { params, headers });
};
// 第二种：Axios请求MockJS数据（二次封装）Api优化版
export const userLogoutApi = (params?: any, headers?: any) => {
  return request.get<any, any>("/user/logout", { params, headers });
};

import type {
  UserStateForm,
  UserStateFormResult,
  UserStateInformationResult,
} from "@/api/user/types";

// 开始登录
export const reqLogin = (
  data: UserStateForm
): AxiosPromise<UserStateFormResult> => {
  return request({
    url: "/admin/acl/index/login",
    method: "post",
    data: data,
  });
};
export const requestLogin = (data: UserStateForm) =>
  request.post("/user/login", data);

// 获取登录
export const reqUserInfo = (): AxiosPromise<UserStateInformationResult> => {
  return request({
    url: "/admin/acl/index/info",
    method: "get",
  });
};
export const requestUserInfo = () => request.get("/user/info");

// 退出登录
export const reqLogout = () => {
  return request({
    url: "/admin/acl/index/logout",
    method: "post",
  });
};
export const requestLogout = () => request.get("/user/logout");
